package com.speedy.course.vm

import android.util.Log
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import com.speedy.course.constant.WeekDay
import com.speedy.course.db.AppDatabase
import com.speedy.course.db.dao.LessonDao
import com.speedy.course.db.entity.Lesson
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow

class WeekViewModel(savedStateHandle: SavedStateHandle) :ViewModel() {

    private var weekDay:Int = savedStateHandle["weekDay"]?: WeekDay.MONDAY

    private val _lessonListStateFlow = MutableStateFlow<List<Lesson>?>(null)
    val lessonListStateFlow = _lessonListStateFlow.asStateFlow()

    private val lessonDao:LessonDao = AppDatabase.getInstance().getLessonDao()



    suspend fun queryLessonList(){
//        lessonDao.queryByWeek(weekDay)
        Log.i("sss", "queryLessonList: ")
        val list = mutableListOf<Lesson>()
        list.add(Lesson())
        list.add(Lesson())
        list.add(Lesson())
        list.add(Lesson())
        list.add(Lesson())
        list.add(Lesson())
        list.add(Lesson())
        _lessonListStateFlow.emit(list)
    }

}